package dao;

import java.util.ArrayList;
import java.util.HashMap;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import util.Utilities;

import dto.ProductDTO;
import dto.WishDTO;

public class WishDAO {
	private SqlMapClientTemplate sqlMap;
	public WishDAO(SqlMapClientTemplate sqlMap) {
		this.sqlMap = sqlMap;
	}
	
	public int selectWishNo(){
		return (Integer) sqlMap.queryForObject("wish.selectWishNo");
	}
	
	public void insertWish(WishDTO wishDTO){
		sqlMap.insert("wish.insertWish",wishDTO);
	}
	
	public void deleteWish(HashMap map){
		sqlMap.delete("wish.deleteWish", map);
	}
	
	public ArrayList<WishDTO> selectWishById(String memberId){
		return (ArrayList<WishDTO>) sqlMap.queryForList("wish.selectWishByMemberId",memberId);
	}
	
	public ProductDTO selectProductByProductId(int productId){
		return (ProductDTO) sqlMap.queryForObject("wish.searchByProductId", productId);
	}
	
	public WishDTO selectWishByIds(HashMap map){
		return (WishDTO) sqlMap.queryForObject("wish.selectWishByIds", map);
	}
	public int selectCountWish(String memberId){
		return (Integer) sqlMap.queryForObject("wish.selectWishCount",memberId);
	}
	
	public ArrayList<ProductDTO > selectWishListByPaging(int page){
		HashMap map = new HashMap();
		map.put("page", page);
		map.put("perPage", Utilities.CONTENT_PER_PAGE);
		return (ArrayList<ProductDTO>) sqlMap.queryForList("wish.selectProductListByPageForWish", map);
	}
	
	
}
